package com.grape.demo_graphql.resolver;

import com.grape.demo_graphql.entity.Asset;
import com.grape.demo_graphql.entity.BankAccount;
import graphql.kickstart.tools.GraphQLResolver;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author robin
 * @Date 2021/11/4
 * @Description
 */
@Slf4j
@Component
public class AssetResolver implements GraphQLResolver<BankAccount> {
        private final ExecutorService service=Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
        public CompletableFuture<List<Asset>> assets(BankAccount bankAccount){
        return CompletableFuture.supplyAsync(
                ()->{
                    log.info("create asset list");
                    return new ArrayList<Asset>();
                },
                service
        );
        }
}
